CC = gcc
LEX = flex
CFLAGS = -g -Wall
LDFLAGS = 
CSOURCES = $(wildcard *.[c])
LEXSOURCES = $(wildcard *.[l])
LEXCSOURCES = $(patsubst %.l, %.c, $(LEXSOURCES))
SOURCES = $(CSOURCES)$(LEXCSOURCES)
OBJS = $(patsubst %.c, %.o, $(SOURCES))

TARGET = cminus-compiler

all : $(OBJS) 
	$(CC) -o $(TARGET) $(OBJS) $(LDFLAGS)
	chmod +x Qcc
	rm -rf $(LEXCSOURCES)
%.o : %.c
	$(CC) -c $(CFLAGS) $< -o $@
%.c : %.l
	$(LEX) -o$@ $< 
clean:
	rm -rf $(OBJS)
	rm -rf $(TARGET)
	rm -rf *~
	rm -rf core*
	rm -rf $(LEXCSOURCES)

